package ioc;

import java.util.Iterator;
import java.util.List;

public class MovieLister {

    private MovieFinder finder = new ColonDelimitedMovieFinder();

    public MovieLister(MovieFinder finder) {
        this.finder = finder;
    }

    public MovieLister() {
    }

    public void setFinder(MovieFinder finder) {
        this.finder = finder;
    }

    public void ShowMoviesDirectedBy(String director) {
        List allMovies = finder.findAll();
        for (Iterator it = allMovies.iterator(); it.hasNext(); ) {
            Movie movie = (Movie) it.next();
            if (!movie.getDirector().equals(director)) {
                it.remove();
            }
        }
        System.out.println(allMovies.toArray());
    }
}